<?php if (!defined('THINK_PATH')) exit(); /*a:3:{s:86:"D:\PHPTutorial\WWW\guyun\public/../application/admin\view\personalcenter\fileList.html";i:1542609108;s:64:"D:\PHPTutorial\WWW\guyun\application\admin\view\common\head.html";i:1541553786;s:66:"D:\PHPTutorial\WWW\guyun\application\admin\view\common\footer.html";i:1515220430;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>上海顾云数据科技中心</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/admin/layui/css/layui.css">
    <link rel="stylesheet" href="/static/admin/build/css/app.css" media="all">
</head>
<style>
    .hidden{
        display: none;
    }

</style>
<script src="/static/admin/layui/layui.js"></script>
<script src="/static/common/js/jquery.min.js"></script>
<script>
//    图片放大显示
    $('.select_img').on('click',function () {
        var img_url=$(this).data('content');
        layer.open({
            type: 1,
            title: false,
            closeBtn: 0,
            area: ['50%','80%'],
            skin: 'layui-layer-nobg', //没有背景色
            shadeClose: true,
            content: '<img src="'+img_url+'" />',
        });
    })
    //文件上传
    layui.use('upload', function(){
        var $ = layui.jquery
            ,upload = layui.upload;
        //多文件列表示例
        var demoListView = $('#demoList')
            ,uploadListIns = upload.render({
            elem: '#testList'
            ,url: '<?php echo url("Upload/file_images"); ?>'
            ,accept: 'file'
            ,multiple: true
            ,auto: false
            ,bindAction: '#testListAction'
            ,choose: function(obj){
                var files = obj.pushFile(); //将每次选择的文件追加到文件队列
                //读取本地文件
                obj.preview(function(index, file, result){
                    var tr = $(['<tr id="upload-'+ index +'">'
                        ,'<td>'+ file.name +'</td>'
                        ,'<td>'+ (file.size/1014).toFixed(1) +'kb</td>'
                        ,'<td>等待上传</td>'
                        ,'<td>'
                        ,'<button class="layui-btn layui-btn-mini demo-reload layui-hide">重传</button>'
                        ,'<button class="layui-btn layui-btn-mini layui-btn-danger demo-delete">删除</button>'
                        ,'</td>'
                        ,'</tr>'].join(''));

                    //单个重传
                    tr.find('.demo-reload').on('click', function(){
                        obj.upload(index, file);
                    });

                    //删除
                    tr.find('.demo-delete').on('click', function(){
                        delete files[index]; //删除对应的文件
                        tr.remove();
                    });

                    demoListView.append(tr);
                });
            }
            ,done: function(res, index, upload){
                if(res.code == 200){ //上传成功
                    var tr = demoListView.find('tr#upload-'+ index)
                        ,tds = tr.children();
                    tds.eq(2).html('<span style="color: #5FB878;">上传成功</span><input type="hidden" name="images['+index+']" value="'+res.data.src+'">');
                    tds.eq(3).html(''); //清空操作
                    delete files[index]; //删除文件队列已经上传成功的文件
                    return;
                }
                this.error(index, upload);
            }
            ,error: function(index, upload){
                var tr = demoListView.find('tr#upload-'+ index)
                    ,tds = tr.children();
                tds.eq(2).html('<span style="color: #FF5722;">上传失败</span>');
                tds.eq(3).find('.demo-reload').removeClass('layui-hide'); //显示重传
            }
        });

        //普通图片上传 单图片上传
        var uploadInst = upload.render({
            elem: '#image'
            ,url: '<?php echo url("Upload/file_images"); ?>'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#show_image').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                //如果上传失败
                if(res.code == 400){
                    return layer.msg('上传失败');
                }
                $('.value_image').val(res.data.src);
                //上传成功
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });
    });
</script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<div style="overflow-x: hidden;width: 96%;margin: auto;padding-top: 1rem;">
<blockquote class="layui-elem-quote"><span>我的顾云&nbsp;&nbsp;&nbsp;&nbsp;文件列表</span></blockquote>
<!--<blockquote class="layui-elem-quote layui-text">-->
  <!--<div class="demoTable layui-form">-->
    <!--&lt;!&ndash;<table class="layui-hide" id="LAY_table_user" lay-filter="user"></table>&ndash;&gt;-->
    <!--<div class="demoTable layui-form">-->
      <!--<div class="layui-input-inline">-->
        <!--<input type="text" placeholder="请输入文件名称" name="name" lay-verify="required|phone"  autocomplete="off" class="layui-input">-->
      <!--</div>-->
      <!--<div class="layui-input-inline">-->
        <!--<input type="text" id="start_time" name="start_time" autocomplete="off" placeholder="开始时间" class="layui-input">-->
      <!--</div>-->
      <!--<div class="layui-input-inline">-->
        <!--<input type="text" id="end_time" name="end_time" autocomplete="off" placeholder="结束时间" class="layui-input">-->
      <!--</div>-->
      <!--<button class="layui-btn " data-type="reload" ><i class="layui-icon">&#xe615;</i>搜索</button>-->
    <!--</div>-->
  <!--</div>-->
<!--</blockquote>-->
<div class="demoTable layui-for">
  <table class="layui-table" lay-data="{height: 'full-170', url:'<?php echo url('Personalcenter/getFileListData'); ?>',edit:true, page:true, id:'testReload',loading:true}" lay-filter="demo">
    <thead>
    <tr>
      <th lay-data="{field:'id',width:411,fixed: true,templet:'#apiid',sort:true}">文件编号</th>
      <th lay-data="{field:'api_name',width:411,fixed: true,templet:'#file_name'}">文件名称</th>
      <th lay-data="{field:'url',width:411,fixed: true,templet:'#url'}">文件地址</th>
      <th lay-data="{field:'solo_price',sort:true,width:411,templet:'#time'}">上传时间</th>
      <!--<th lay-data="{width:329,fixed: 'right', align:'left', toolbar: '#barDemo'}">操作</th>-->
    </tr>
    </thead>
  </table>
  <!--<script type="text/html" id="barDemo">-->
    <!--<a id="collect" title="删除文件" lay-event="delete" href="#"><i class="layui-icon" style="font-size: 25px; color:#029587;line-height: 30px">&#xe640;</i></a>&nbsp;&nbsp;&nbsp;-->
  <!--</script>-->
</div>
<script src="/static/admin/jquery.js"></script>
<script type="text/javascript" src="/static/index/layer/layer.js"></script>
<script type="text/html" id="apiid">
  <span>{{d.id}}</span>
</script>
<script type="text/html" id="file_name">
  <span>{{d.file_name}}</span>
</script>
<script type="text/html" id="url">
  <span><a download="" href="{{d.url}}" title="点击下载文件">{{d.url}}</a></span>
</script>
<script type="text/html" id="time">
  <span>{{d.add_time}}</span>
</script>
<script>
    layui.use(['table','form'], function(){
        var table = layui.table
            ,form = layui.form;
        var $ = layui.$, active = {
            reload: function(){
                var name = $('input[name="name"]').val();
                var start_time = $('input[name="start_time"]').val();
                var end_time = $('input[name="end_time"]').val();
                //执行重载
                table.reload('testReload', {
                    where: {
                        name:name,
                        start_time:start_time,
                        end_time:end_time
                    }
                });
            }
        };

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        //监听工具条
        table.on('tool(demo)', function(obj){
            var data = obj.data;
            if(obj.event === 'delete'){
                layer.confirm('确定删除么', function(index){
                    $.ajax({
                        url:'<?php echo url("Personalcenter/deleteFile"); ?>',
                        type:'post',
                        dataType:'json',
                        data: {'file_id':data.id},
                        success:function(val){
                            if(val.code ==200){
                                obj.del();
                                layer.msg(val.msg);
                            }
                            if(val.code==400){
                                layer.msg(val.msg);
                            }
                        }
                    });

                });
            }
        });
    });
</script>

<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        var endDate= laydate.render({
            elem: '#end_time',//选择器结束时间
            type: 'datetime',
            min:"1970-1-1",//设置min默认最小值
            done: function(value,date){
                startDate.config.max={
                    year:date.year,
                    month:date.month-1,//关键
                    date: date.date,
                    hours: 0,
                    minutes: 0,
                    seconds : 0
                }
            }
        });
        //日期范围
        var startDate=laydate.render({
            elem: '#start_time',
            type: 'datetime',
            max:"2099-12-31",//设置一个默认最大值
            done: function(value, date){
                endDate.config.min ={
                    year:date.year,
                    month:date.month-1, //关键
                    date: date.date,
                    hours: 0,
                    minutes: 0,
                    seconds : 0
                };
            }
        });

    });
</script>
</div>

</body>
</html>